package Code;

import java.awt.BorderLayout;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import Panels.DatabaseHome;
import Panels.WithSSH;
import Panels.WithoutSSH;


public class Window{
	
	private static Window Instance=null;
	public JFrame MainWindow;
	public JTabbedPane TabbedFrame;
	public DatabaseHome HomePanel;

	
	protected Window(){
		
	}
	
	public void CreateWindow(){
		MainWindow=new JFrame("Database Access");
		MainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		MainWindow.setLayout(new BorderLayout());
		MainWindow.setBounds(0,0,900,500);
		MainWindow.setLocationRelativeTo(null);
		
		TabbedFrame=new JTabbedPane();

		
		TabbedFrame.addTab("Connect without SSH(on school network)",null,new WithoutSSH(),null);
		TabbedFrame.addTab("Connect with SSH(not on school network)",null,new WithSSH(),null);
		TabbedFrame.setFont(new Font("Serif",Font.PLAIN,16));
		
		MainWindow.getContentPane().add(TabbedFrame,BorderLayout.CENTER);
		
		MainWindow.setVisible(true);
	}
	
	
	public void SwitchToDatabaseHome(){
		HomePanel=DatabaseHome.getInstance();
		TabbedFrame.setVisible(false);
		MainWindow.getContentPane().remove(TabbedFrame);
		MainWindow.getContentPane().add(HomePanel);
	}
	
	
	public static Window getInstance(){
		if(Instance==null){
			Instance=new Window();
		}
		return Instance;
	}

}
